package com.ztao.controller;

import com.heima.model.common.admin.dto.NewsAuthDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.wemedia.dtos.WmNewsDownOrUpDto;
import com.heima.model.common.wemedia.dtos.WmNewsDto;
import com.heima.model.common.wemedia.dtos.WmNewsPageReqDto;
import com.ztao.service.NewsAuthService;
import com.ztao.service.WmNewsService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {
    @Resource
    private WmNewsService wmNewsService;
    @Resource
    private NewsAuthService newsAuthService;
    @PostMapping("/list")
    public ResponseResult findAll(@RequestBody WmNewsPageReqDto dto){
        return wmNewsService.findAll(dto);
    }
    @GetMapping("/del_news/{id}")
    public ResponseResult delNews(@PathVariable("id") Integer id){
        return wmNewsService.delNews(id);
    }

    @PostMapping("/submit")
    public ResponseResult submitNews(@RequestBody WmNewsDto dto){
        return wmNewsService.submitNews(dto);
    }

    @PostMapping("/down_or_up")
    public ResponseResult downOrUp(@RequestBody WmNewsDownOrUpDto dto){
        return wmNewsService.downOrUp(dto);
    }

    //媒体审核页面
    @PostMapping("/list_vo")
    public ResponseResult findAllVo(@RequestBody NewsAuthDto dto) {
        return newsAuthService.findAll_news(dto);

    }

    @GetMapping("one_vo/{id}")
    public ResponseResult findOneVo(@PathVariable("id") Integer id) {
        return newsAuthService.findNewsById(id);
    }
    //驳回
    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody NewsAuthDto dto){
        return newsAuthService.authFail(dto);
    }
    //通过
    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody NewsAuthDto dto){
        return newsAuthService.authPass(dto);
    }
}
